package lab.muilt;

import java.util.HashMap;
import java.util.Map;

public class Node {
	private Object key;
	private Object value;
	private Node parentNode;
	private Node defaultChildNode;
	private Map<Object, Node> childNodeMap = new HashMap<Object, Node>();

	public Node(Object key) {
		this.key = key;
	}

	public Object getKey() {
		return key;
	}

	public Object getValue() {
		return value;
	}

	protected void setValue(Object value) {
		this.value = value;
	}

	public Node getParentNode() {
		return parentNode;
	}

	private void setParentNode(Node parent) {
		this.parentNode = parent;
	}

	public Node getChildNode(Object key) {
		return childNodeMap.get(key);
	}

	public Node getDefaultChild() {
		return defaultChildNode;
	}

	public boolean hasChildNode() {
		return childNodeMap.size() > 0;
	}

	public boolean hasDefaultChild() {
		return defaultChildNode != null;
	}

	public void addChildNode(Node child) {
		childNodeMap.put(child.getKey(), child);
		child.setParentNode(this);
	}

	public void addDefaultChild(Node child) {
		this.defaultChildNode = child;
	}
}
